package com.ccy.net;

import java.io.IOException;
import java.io.InputStream;

import com.ccy.utils.IoUtils;

public class LoadWeatherTask implements Runnable {

	private WeatherDownloader mDownloader;

	private String mCityName;

	public LoadWeatherTask(WeatherDownloader downloader, String cityName) {
		this.mCityName = cityName;
		this.mDownloader = downloader;
	}

	@Override
	public void run() {
		InputStream streamFromNetwork = null;
		try {
			streamFromNetwork = mDownloader.getStreamFromNetwork("http://weather.3gpk.net/android/httpHead/weather.aspx?city=" + mCityName);
			System.err.println(Thread.currentThread().getName() + " " + streamFromNetwork.toString());
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			IoUtils.closeSilently(streamFromNetwork);
		}
	}

}
